package a.f;

import a.d.*;
import a.d.s;
import a.d.t;
import a.d.w;
import a.d.x;
import a.d.y;

public class kd
  implements xb
{
  public static final byte a = 0;
  public static final byte b = 1;
  public static final byte c = 0;
  public static final byte d = 1;
  public static final byte e = 2;
  public static final byte f = 3;
  public static final byte g = 4;
  private static final double h = 1.0E-006D;
  private double i = 1.0D;
  private double j = 1.0D;
  private double k = 1.0D;
  private double l = 9.125D;
  private byte m;
  private static final a_ n = new a_(0, 0.0D, new a.d.z(0.0D, 0.0D), (byte)2, 0.0D);
  private static final a_ o = new a_(0, 0.0D, new a.d.z(0.0D, 0.0D), (byte)0, 0.0D);
  public static int p;
  
  public kd(byte paramByte)
  {
    this.m = paramByte;
  }
  
  public byte b()
  {
    return this.m;
  }
  
  public void a(double paramDouble1, double paramDouble2)
  {
    this.i = paramDouble1;
    this.j = paramDouble2;
  }
  
  public double c()
  {
    return this.j;
  }
  
  public void a(double paramDouble)
  {
    this.j = paramDouble;
  }
  
  public double d()
  {
    return this.i;
  }
  
  public void b(double paramDouble)
  {
    this.i = paramDouble;
  }
  
  public double e()
  {
    return this.k;
  }
  
  public void c(double paramDouble)
  {
    this.k = paramDouble;
  }
  
  public double f()
  {
    return this.l;
  }
  
  public void d(double paramDouble)
  {
    this.l = paramDouble;
  }
  
  public Object a()
  {
    if (this.m == 1) {
      return n;
    }
    return o;
  }
  
  public a.d.o a(s params, zb paramzb, zc paramzc1, zc paramzc2, Object paramObject)
  {
    boolean bool = o.eg;
    if (!bool) {}
    a_ locala_ = paramObject != null ? (a_)paramObject : (a_)a();
    int i1 = locala_.a();
    byte b1 = locala_.d();
    double d1 = locala_.b();
    a.d.z localz = locala_.c();
    y localy = wc.a(paramzb, paramzc1, paramzc2, this.l);
    if (!bool) {}
    int i2 = i1 < 0 ? localy.j() - 1 + i1 : i1;
    n localn = localy.a(i2);
    a.d.o localo = new a.d.o(new w(0.0D, 0.0D), params);
    t localt = localo.a();
    if (!bool) {
      if (localn == null)
      {
        localo.g(paramzc1.a() + localt.a * 0.5D, paramzc1.b() + localt.b * 0.5D);
        return localo;
      }
    }
    w localw1 = localn.d();
    w localw2 = localn.e();
    if ((bool) || (localn.h() == 0.0D))
    {
      double d2 = paramzc1.a() + paramzc1.c() * 0.5D + paramzb.c().a - (paramzc2.a() + paramzc2.c() * 0.5D + paramzb.d().a);
      double d3 = paramzc1.b() + paramzc1.d() * 0.5D + paramzb.c().b - (paramzc2.b() + paramzc2.d() * 0.5D + paramzb.d().b);
      if (!bool) {
        if (d2 == 0.0D)
        {
          if (bool) {
            break label400;
          }
          if (d3 == 0.0D)
          {
            if (bool) {
              break label459;
            }
            localw2 = new w(localw1.a + 1.0E-006D, localw1.b);
            if (o.dg == 0) {
              break label445;
            }
          }
        }
      }
      label400:
      double d4 = Math.sqrt(d2 * d2 + d3 * d3);
      localw2 = new w(localw1.a + 1.0E-006D * d2 / d4, localw1.b + 1.0E-006D * d3 / d4);
    }
    label445:
    label459:
    w localw3 = a(d1, localw1, localw2, localt, b1);
    w localw4 = a.d.z.a(localw3, localz);
    localw4 = w.b(localw4, localw1);
    localo.g(localw4.a() + localt.a * 0.5D, localw4.b() + localt.b * 0.5D);
    return localo;
  }
  
  public a.c.z a(wb paramwb, zb paramzb, zc paramzc1, zc paramzc2)
  {
    boolean bool2 = o.eg;
    int i6 = o.dg;
    byte[] arrayOfByte = a(this.m);
    a.d.o localo1 = ob.a(paramwb.d());
    double d1 = localo1.g();
    double d2 = localo1.h();
    s locals = new s(d1, d2);
    a.c.z localz = new a.c.z();
    y localy = wc.a(paramzb, paramzc1, paramzc2, this.l);
    x localx = localy.b();
    if (!bool2) {
      if (!localx.e())
      {
        localo1.g(paramzc1.a() + d1 * 0.5D, paramzc1.b() + d2 * 0.5D);
        localObject = new gc(localo1, a(), paramwb, false);
        localz.add(localObject);
        return localz;
      }
    }
    Object localObject = new double[localy.j() - 1];
    double[] arrayOfDouble1 = new double[localy.j() - 1];
    double d3 = a(localy, (double[])localObject, arrayOfDouble1);
    w localw1 = localx.a();
    localx.f();
    int i1 = 0;
    label288:
    label334:
    label344:
    label609:
    label622:
    do
    {
      do
      {
        if (!localx.e()) {
          break;
        }
        break label288;
        w localw2 = localw1;
        localw1 = localx.a();
        double d4 = localw1.a() - localw2.a();
        double d5 = localw1.b() - localw2.b();
        double[] arrayOfDouble2 = a(d4, d5, d1, d2);
        int i2 = 0;
        do
        {
          if (i2 >= arrayOfByte.length) {
            break label622;
          }
          boolean bool1 = false;
          if (i6 != 0) {
            break;
          }
          if (arrayOfByte[i2] == 0) {
            bool1 = true;
          }
          a.d.z localz1 = a(d4, d5, d1, d2, arrayOfByte[i2]);
          a.d.z localz2 = a.d.z.b(localz1);
          localz2.b(this.i);
          int i3 = 0;
          i3++;
          int i4 = 0;
          do
          {
            do
            {
              if (i4 >= arrayOfDouble2.length) {
                break label551;
              }
              double d6 = arrayOfDouble2[i4];
              w localw3 = a(d6, localw2, localw1, locals, arrayOfByte[i2]);
              w localw4 = a.d.z.a(localw3, localz2);
              localw4 = w.b(localw4, localw2);
              double d7 = arrayOfDouble1[i1] / d3 + d6 * localObject[i1];
              if (i6 != 0) {
                break;
              }
              int i5 = i1 > (localy.j() - 2) / 2 ? i1 + 1 - localy.j() : i1;
              a_ locala_ = new a_(i5, d6, localz2, arrayOfByte[i2], d7);
              a.d.o localo2 = new a.d.o(localo1);
              localo2.g(localw4.a() + d1 * 0.5D, localw4.b() + d2 * 0.5D);
              gc localgc = new gc(localo2, locala_, paramwb, bool1);
              localz.add(localgc);
              i4++;
            } while (i6 == 0);
            if (bool2) {
              break label334;
            }
            localz2.a(localz1);
            if (a.d.z.a(localz2, localz1).d() < this.j)
            {
              if (bool2) {
                break label609;
              }
              if ((this.m != 0) && (i3 < 5)) {
                break label344;
              }
            }
            i2++;
          } while (bool2);
          do
          {
            if (i6 != 0) {
              break;
            }
          } while (bool2);
        } while (i6 == 0);
        localx.f();
        i1++;
      } while (bool2);
    } while (i6 == 0);
    label551:
    return localz;
  }
  
  public Object a(a.d.o paramo, zb paramzb, zc paramzc1, zc paramzc2)
  {
    boolean bool = o.eg;
    if (wc.a(paramo)) {
      throw new IllegalArgumentException("Invalid label bounds: " + paramo);
    }
    mc localmc = new mc();
    localmc.a(paramo);
    a.c.z localz = a(localmc, paramzb, paramzc1, paramzc2);
    if (!bool) {
      if (localz.isEmpty()) {
        return a();
      }
    }
    fc localfc = ob.a(localz, paramo.l());
    if (!bool) {}
    return localfc != null ? localfc.c() : a();
  }
  
  public a.d.z a(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4, byte paramByte)
  {
    boolean bool = o.eg;
    if (paramByte == 0) {
      return new a.d.z(0.0D, 0.0D);
    }
    double d1 = Math.abs(paramDouble1);
    double d2 = Math.abs(paramDouble2);
    double d3 = paramDouble2 / paramDouble1;
    if (!bool)
    {
      if (Double.isNaN(d3)) {
        d3 = 1.0D;
      }
      paramDouble3 = Math.max(0.01D, paramDouble3);
      paramDouble4 = Math.max(0.01D, paramDouble4);
    }
    double d4 = paramDouble4 / paramDouble3;
    double d5 = paramDouble3 * 0.5D;
    double d6 = paramDouble4 * 0.5D;
    if (!bool) {
      if (d2 < d1 * d4)
      {
        d7 = d6 + Math.abs(d5 * d3);
        if (a(paramByte, paramDouble1, paramDouble2)) {
          return new a.d.z(0.0D, -d7);
        }
        return new a.d.z(0.0D, d7);
      }
    }
    double d7 = d5 + Math.abs(d6 / d3);
    if (b(paramByte, paramDouble1, paramDouble2)) {
      return new a.d.z(-d7, 0.0D);
    }
    return new a.d.z(d7, 0.0D);
  }
  
  private static byte[] a(byte paramByte)
  {
    boolean bool = o.eg;
    if (!bool) {
      if (paramByte == 0) {
        return new byte[] { 0 };
      }
    }
    if ((bool) || (paramByte == 1)) {
      return new byte[] { 3, 4 };
    }
    throw new IllegalArgumentException("Unknown model mode " + paramByte);
  }
  
  private double[] a(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
  {
    boolean bool = o.eg;
    int i3 = o.dg;
    paramDouble1 = Math.abs(paramDouble1);
    paramDouble2 = Math.abs(paramDouble2);
    paramDouble3 = Math.max(0.01D, paramDouble3);
    if (!bool) {
      if (paramDouble2 < paramDouble1 * paramDouble4 / paramDouble3)
      {
        i1 = Math.max(2, (int)Math.floor(paramDouble1 / paramDouble3));
        if (bool) {
          break label130;
        }
        if (i3 == 0) {
          break label85;
        }
      }
    }
    int i1 = Math.max(2, (int)Math.floor(paramDouble2 / paramDouble4));
    label85:
    if (!bool)
    {
      i1 = (int)(i1 + (this.k - 1.0D) * (i1 - 1));
      i1 = Math.min(i1, 20);
      i1 = Math.max(3, i1);
      if (i1 % 2 == 0) {
        i1++;
      }
    }
    label130:
    double d1 = 1.0D / (i1 - 1);
    double[] arrayOfDouble = new double[i1];
    int i2 = i1 - 2;
    if (i2 > 0)
    {
      if (bool) {}
    }
    else
    {
      while (bool)
      {
        arrayOfDouble[i2] = (d1 * i2);
        i2--;
        if (i3 != 0) {
          break label204;
        }
        if (i3 == 0) {
          break;
        }
      }
      arrayOfDouble[(i1 - 1)] = 1.0D;
    }
    label204:
    return arrayOfDouble;
  }
  
  private w a(double paramDouble, w paramw1, w paramw2, s params, byte paramByte)
  {
    boolean bool = o.eg;
    int i1 = o.dg;
    double d1 = paramw2.a() - paramw1.a();
    double d2 = paramw2.b() - paramw1.b();
    double d3 = Math.max(1.0E-007D, Math.abs(d1));
    double d4 = Math.abs(d2);
    double d5 = d2 / d1;
    if (!bool) {
      if (Double.isNaN(d5)) {
        d5 = 1.0D;
      }
    }
    double d6 = Math.max(0.01D, params.b());
    double d7 = Math.max(0.01D, params.c());
    double d8 = d7 / d6;
    double d13 = d6 * 0.5D;
    double d14 = d7 * 0.5D;
    if (!bool) {
      if (d4 < d3 * d8)
      {
        if (!bool) {
          if (d1 > 0.0D)
          {
            if (bool) {
              break label175;
            }
            d9 = 1.0D + d13;
            if (i1 == 0) {
              break label177;
            }
          }
        }
        label175:
        d9 = -(1.0D + d13);
        label177:
        d11 = d1 - d9;
        d10 = d5 * d9;
        d12 = d2 - d10;
        if (paramByte == 0) {
          break label421;
        }
        d15 = d14 + Math.abs(d13 * d5);
        if (!bool)
        {
          if (a(paramByte, d1, d2))
          {
            d10 -= d15;
            d12 -= d15;
            if (bool) {
              break label428;
            }
            if (i1 == 0) {
              break label421;
            }
          }
          d10 += d15;
          d12 += d15;
          if (bool) {
            break label428;
          }
        }
        if (i1 == 0) {
          break label421;
        }
      }
    }
    double d15 = 1.0D / d5;
    if (!bool) {
      if (d2 > 0.0D)
      {
        if (bool) {
          break label320;
        }
        d10 = 1.0D + d14;
        if (i1 == 0) {
          break label322;
        }
      }
    }
    label320:
    double d10 = -(1.0D + d14);
    label322:
    double d12 = d2 - d10;
    double d9 = d10 / d5;
    double d11 = d1 - d9;
    double d16;
    if (!bool)
    {
      if (paramByte != 0)
      {
        d16 = d13 + Math.abs(d14 * d15);
        if (!bool)
        {
          if (b(paramByte, d1, d2))
          {
            d9 -= d16;
            d11 -= d16;
            if (bool) {
              break label442;
            }
            if (i1 == 0) {}
          }
          else
          {
            d9 += d16;
          }
        }
        else {
          d11 += d16;
        }
      }
      label421:
      d15 = d11 - d9;
    }
    else
    {
      label428:
      d16 = d12 - d10;
    }
    label442:
    if ((bool) || ((d15 * d1 < 0.0D) || (d16 * d2 < 0.0D))) {
      return new w((d9 + d11) * 0.5D - d13, (d10 + d12) * 0.5D - d14);
    }
    return new w(d9 + d15 * paramDouble - d13, d10 + d16 * paramDouble - d14);
  }
  
  private static boolean a(byte paramByte, double paramDouble1, double paramDouble2)
  {
    boolean bool = o.eg;
    if (!bool)
    {
      if (paramByte == 2) {
        return true;
      }
      if (bool) {}
    }
    else if (paramByte == 1)
    {
      return false;
    }
    if (!bool) {
      if (paramDouble1 > 0.0D)
      {
        if (bool) {
          break label55;
        }
        if (paramByte == 3) {
          return true;
        }
      }
    }
    label55:
    if (!bool) {
      if (paramDouble1 < 0.0D)
      {
        if (bool) {
          break label76;
        }
        if (paramByte == 4) {
          return true;
        }
      }
    }
    label76:
    return false;
  }
  
  private static boolean b(byte paramByte, double paramDouble1, double paramDouble2)
  {
    boolean bool = o.eg;
    if (!bool)
    {
      if (paramByte == 2) {
        return true;
      }
      if (bool) {}
    }
    else if (paramByte == 1)
    {
      return false;
    }
    if (!bool) {
      if (paramDouble2 > 0.0D)
      {
        if (bool) {
          break label55;
        }
        if (paramByte == 4) {
          return true;
        }
      }
    }
    label55:
    if (!bool) {
      if (paramDouble2 < 0.0D)
      {
        if (bool) {
          break label76;
        }
        if (paramByte == 3) {
          return true;
        }
      }
    }
    label76:
    return false;
  }
  
  private double a(y paramy, double[] paramArrayOfDouble1, double[] paramArrayOfDouble2)
  {
    boolean bool = o.eg;
    int i2 = o.dg;
    w localw1 = null;
    w localw2 = null;
    x localx = paramy.b();
    if (!localx.e()) {
      return 0.0D;
    }
    double d1 = 0.0D;
    localw1 = localx.a();
    localx.f();
    if (localx.e())
    {
      localw2 = localw1;
      localw1 = localx.a();
    }
    do
    {
      d2 = localw2.a() - localw1.a();
      double d3 = localw2.b() - localw1.b();
      d1 += Math.sqrt(d2 * d2 + d3 * d3);
      localx.f();
      if (bool) {
        break label174;
      }
      if (i2 != 0) {
        break label173;
      }
      if (i2 == 0) {
        break;
      }
      localx = paramy.b();
      localw1 = localx.a();
      localx.f();
    } while (bool);
    double d2 = 0.0D;
    label173:
    label174:
    int i1 = 0;
    if (localx.e())
    {
      localw2 = localw1;
      localw1 = localx.a();
    }
    while (bool)
    {
      double d4 = localw2.a() - localw1.a();
      double d5 = localw2.b() - localw1.b();
      double d6 = Math.sqrt(d4 * d4 + d5 * d5);
      paramArrayOfDouble2[i1] = d2;
      paramArrayOfDouble1[i1] = (d6 / d1);
      if (!bool)
      {
        if (i2 != 0) {
          break label295;
        }
        d2 += d6;
        i1++;
        localx.f();
      }
      if (i2 == 0) {
        break;
      }
    }
    label295:
    return d1;
  }
  
  public static class a_
  {
    private int a;
    private double b;
    private double c;
    private a.d.z d;
    private byte e;
    public static boolean f;
    
    public a_(int paramInt, double paramDouble1, a.d.z paramz, byte paramByte, double paramDouble2)
    {
      this.a = paramInt;
      this.b = paramDouble1;
      this.d = new a.d.z(paramz);
      this.e = paramByte;
      this.c = paramDouble2;
    }
    
    public int a()
    {
      return this.a;
    }
    
    public double b()
    {
      return this.b;
    }
    
    public a.d.z c()
    {
      return this.d;
    }
    
    public byte d()
    {
      return this.e;
    }
    
    public double e()
    {
      return this.c;
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.kd

 * JD-Core Version:    0.7.0.1

 */